package demo1208.pm.example;

/*
■ ■
■ ■
 */
public class CellO {
    //    成员变量
    private Cell[] cells;

    //    构造方法
    public CellO(Cell c) {//传入一个坐标点(2,3)
        //给成员变量初始化值.
        cells = new Cell[4];
        cells[0] = c;
        cells[1] = new Cell(c.getRow(), c.getCol() + 1);
        cells[2] = new Cell(c.getRow() + 1, c.getCol());
        cells[3] = new Cell(c.getRow() + 1, c.getCol() + 1);
    }

    public void print() {
//        总行数
        int totalRow = 20;
//        总列数
        int totalCol = 10;

        for (int i = 1; i <= totalRow; i++) {
            for (int j = 1; j <= totalCol; j++) {
                /*
                打印方块图形,判断当前坐标点在不在数组中,如果在打印实心方块,
                不在,打印空心方块.
                (1,1)
                 */
//做标记  假设当前坐标点不在数组中
                boolean flag = false;
                for (int k = 0; k < cells.length; k++) {
                    if (cells[k].getRow() == i && cells[k].getCol() == j) {
                        flag = true;
                        break;
                    }
                }
                if (flag) {
                    System.out.print("■ ");
                } else {
                    System.out.print("□ ");
                }


            }
            System.out.println();
        }
    }
}
